/**
 * @param {string} s
 * @return {boolean}
 */
var isValid = function (s) {
    let nLength = s.length;
    if (nLength % 2 === 1) {
        return false;
    }
    let localMap = new Map([
        [")", "("],
        ["]", "["],
        ["}", "{"],
    ]);
    let str = [];
    for (let ch of s) {
        if (localMap.has(ch)) {
            if (!str.length || str[str.length - 1] !== localMap.get(ch)) {
                return false;
            }
            str.pop();
        } else {
            str.push(ch);
        }
    }
    return !str.length;
};
